<?php
/**
 * 
 * @author Radovan Dvorsky
 * @version 20091228
 *
 */
class Zend_View_Helper_LinkToSubmit extends Zend_View_Helper_Abstract
{	
	
	public function linkToSubmit($linkId,$linkName,$iconType = null)
    {
        $jquery = $this->view->jQuery();
        $jquery->enable(); // enable jQuery Core Library

        // get current jQuery handler based on noConflict settings
       $jqHandler = ZendX_JQuery_View_Helper_JQuery::getJQueryHandler();		
     	
				
       $function = '("a#'.$linkId.'").click(function(){'
        		  . 	'$("form").submit();'
        		  . '});';        		  

        
        $jquery->addOnload($jqHandler . $function);

        if($iconType != null){
        	$link =  '<a href="#" id="' . $linkId . '"><div class="icon ' . $iconType . '"></div>' . $linkName . '</a>';
        }
        else {
        	$link =  '<a href="#" id="' . $linkId . '">' . $linkName . '</a>';
        }
        
        return $link;
    }
}